package com.yuqing.sentimentapp.utils.net;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;

/**
 * Created by vread on 2016/9/1.
 */
public class NetCheckReceiver extends BroadcastReceiver {
    public static final String NET_CHANGE_ACTION = "android.net.conn.CONNECTIVITY_CHANGE";
    @Override
    public void onReceive(Context context, Intent intent) {
        if (NET_CHANGE_ACTION.equals(intent.getAction())) {
            // Intent中ConnectivityManager.EXTRA_NO_CONNECTIVITY这个关键字表示着当前是否连接上了网络
            // true 代表网络断开 false 代表网络没有断开
            boolean isBreak = intent.getBooleanExtra(
                    ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
            if (!isBreak) {
//                PaymentMonthMineUtil.getInstance().reqPaymentMonth();
                context.unregisterReceiver(this);
            }
        }
    }
}
